{include file="public/header"}
{load href="/public/static/Content/ThemesBusiness/ListPage.css"}
<style>
    .datagrid-view {
        overflow-x: scroll;
    }
</style>
<script src="/public/static/Scripts/common-binder-list-view.js"></script>
<script src="/public/static/Scripts/ScriptsEasyui/datagrid-filter.js"></script>
<link rel="stylesheet" href="/public/static/css/loading.css" />
<script type="text/javascript">
    
    function ShowNew() {
        $.messager.confirm('提示', '备份数据的时间较长，确定要备份所有数据吗?', function (r) {
            if (r) {
                $.ajax({
                    type: "POST",
                    url: '/admin/backup/index.html?type=backup',
                })
                    .success(function (result) {
                        console.log(result);
                        if(result.code==1){
                            //$.messager.alert('成功', result.msg, 'info');
                            $("#jiazai").show();
                            setTimeout(function(){
                                //$('#datagrid').datagrid('reload');
                                 window.location.reload();
                             },3000);
                            
                        }else{
                            $.messager.alert('错误', "备份失败", 'error');
                        }
                       
                    })
                    .error(function (result) {
                        $.messager.alert('错误', "备份失败", 'error');
                    });
            }
        });
      
    }


   

    //還原
    function hy(name) {
        //alert(name);
        $.messager.confirm('提示', '备份还原后仅会显示当前备份的数据库的信息，您确定还原备份吗 ?', function (r) {
            $("#jiazai").show();
            if (r) {
                $.ajax({
                    type: "POST",
                    url: '/admin/backup/index.html?type=restore&name='+name,
                })
                    .success(function (result) {
                        // console.log(result);
                        // if(result.code==1){
                        //     $.messager.alert('成功', '还原成功', 'info');
                        // }else{
                        //     $.messager.alert('错误', "还原失败", 'error');
                        // }
                       
                    })
                    .error(function (result) {
                        console.log(result);
                        $("#jiazai").show();
                        //$.messager.alert('错误', "还原失败", 'error');
                        $.messager.alert('成功', '还原成功', 'info');
                        setTimeout(function(){
                                 window.location.reload();
                        },3000);
                    });
                    //$.messager.alert('错误', "还原失败111", 'error');
            }
        });
      
    }

    
    //刪除
    function del(name) {
        //alert(name);
        $.messager.confirm('提示', '数据库备份一旦删除不可找回，您确定操作吗?', function (r) {
           
            if (r) {
                $.ajax({
                    type: "POST",
                    url: '/admin/backup/index.html?type=del&name='+name,
                })
                    .success(function (result) {
                        console.log(result);
                        if(result.code==1){
                            $.messager.alert('成功', result.msg, 'info');
                            window.location.reload();
                        }else{
                            $.messager.alert('错误', "刪除失败", 'error');
                        }
                       
                    })
                    .error(function (result) {
                        $.messager.alert('错误', "刪除失败", 'error');
                    });
            }
        });
      
    }




   

   

    function formatAction(val, row, index) {
        //console.log(row.name);

        val = '{eq name="power.edit" value="true"}<a href="/admin/backup/index.html?type=dowonload&name='+row.name+'" style="color:#1024EE;"   title="下载">下载</a>' +
            '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="#" style="color:#1024EE;"  title="还原" onclick="hy(`' + row.name + '`);">还原</a>' +
            '&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="#" style="color:#1024EE;" title="删除" onclick="del(`' + row.name + '`)">删除</a>{/eq}';

        return val;

    }
 

</script>

<div style="display: none;position: absolute;width: 100%;height: 100%;z-index: 100;background-color: rgba(0,0,0,0.3);" id="jiazai">
    <div class="spinner" style="position: absolute;left: 50%;top: 20%;border: none;overflow: visible;">
        <div class="spinner-container container1">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
        <div class="spinner-container container2">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
        <div class="spinner-container container3">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
    </div>
</div>




<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false" class="grid-toolbar-panel" id="gridList_ToolBar">

        <a href="#" id="new" onclick="ShowNew()" class="easyui-linkbutton grid-toolbar-button"
            data-options="iconCls:'icon-add'" title="添加备份">添加备份</a>
     
    </div>
    <div data-options="region:'center',border:false">
        <table id="datagrid" class="easyui-datagrid"  data-options="pagination:true,pageSize:15,pageList:[10,15,20],multiSort:true,remoteSort:true,striped:true,fit:true,fitColumns:true,rownumbers:true,idField:'_ID',singleSelect: true"
        url="/admin/backup/index.html?ajax=1">
            <thead>
                <tr>
                    <th data-options="field:'id',formatter:formatAction,width:120,halign:'center',align:'center',filterable:false">操作</th>
                    <th data-options="field:'name',halign:'center',align:'left',width:120,filterable:false">备份名称
                    </th>
                    <th data-options="field:'time',halign:'center',align:'left',width:120,filterable:false"><span
                            class="grid-header-sortable">备份时间</span></th>
                    <th data-options="field:'size',halign:'center',align:'left',width:120,filterable:false">
                        <span class="grid-header-sortable">备份大小</span></th>
                </tr>
            </thead>
            <tbody>
               
            </tbody>
        </table>
      
    </div>
   
</div>

{include file="public/footer"/}